<template>
  <view class="item">
    <view class="left">
      <!-- 单选按钮 -->
      <radio @click="radioClick(item.goods_id)" v-if="isShow" :checked="item.goods_status" color="#c00000"></radio>
      <image :src="item.goods_small_logo || '../../static/logo.png'" mode=""></image>
    </view>
    <view class="right">
      <view class="info">
        {{item.goods_name}}
      </view>
      <view class="price">
        <!-- 过滤器注意点：只能用于v-bind与{{}} 它内部不能使用this 
        过滤器作用：字符加工
          定义
            全局过滤器
              Vue.filter('过滤器名字',(参数)=>{return 值})
            局部过滤器
              filters:{
                过滤器名字(参数){
                  return 值
                }
              }
         使用
           {{ 实参 |  过滤器名字 }}
           
        vue3不能使用过滤器，
       
        -->
        <text>￥{{item.goods_price | formatPrice}}</text>
        <uni-number-box @change="changeEvent" v-model="item.goods_count" :min="1"
          :max="item.goods_number"></uni-number-box>
      </view>
    </view>
  </view>
</template>

<script>
  export default {
    name: "my-goods",
    props: {
      item: {
        type: Object,
        required: true
      },
      isShow: {
        type: Boolean,
        default: false
      }
    },
    filters: {
      formatPrice(price) {
        return price.toFixed(2)
      }
    },
    data() {
      return {

      };
    },
    methods: {
      radioClick(id) {
        this.$emit('changeStatus', id)
      },
      changeEvent(value) {
        this.$emit('changeCount', {
          goods_id: this.item.goods_id,
          goods_count: value
        })
      }
    }
  }
</script>

<style lang="scss" scoped>
  .item {
    display: flex;
    padding: 20rpx;
    font-size: 12px;
    border-bottom: 1px solid #f8f7f7;

    .left {
      display: flex;
      align-items: center;

      image {
        width: 200rpx;
        height: 200rpx;
        margin-right: 20rpx;
      }
    }

    .right {
      display: flex;
      flex-direction: column;
      justify-content: space-between;

      .price {
        display: flex;
        justify-content: space-between;

        text {
          color: #c00000;
          font-size: 16px;
        }
      }
    }
  }
</style>